package com.abvnet.project.water.project.service;

import com.abvnet.common.utils.security.ShiroUtils;
import com.abvnet.common.utils.text.Convert;
import com.abvnet.project.water.project.domain.ProjectMicrobial;
import com.abvnet.project.water.project.mapper.ProjectMicrobialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菌剂 服务层实现
 * 
 * @author duj
 * @date 2019-07-02
 */
@Service
public class ProjectMicrobialServiceImpl implements IProjectMicrobialService {
	@Autowired
	private ProjectMicrobialMapper projectMicrobialMapper;

	/**
     * 查询菌剂信息
     * 
     * @param microbialId 菌剂ID
     * @return 菌剂信息
     */
    @Override
	public ProjectMicrobial selectProjectMicrobialById(Long microbialId) {
	    return projectMicrobialMapper.selectProjectMicrobialById(microbialId);
	}
	
	/**
     * 查询菌剂列表
     * 
     * @param projectMicrobial 菌剂信息
     * @return 菌剂集合
     */
	@Override
	public List<ProjectMicrobial> selectProjectMicrobialList(ProjectMicrobial projectMicrobial) {
	    return projectMicrobialMapper.selectProjectMicrobialList(projectMicrobial);
	}

    @Override
    public List<ProjectMicrobial> selectListForApi() {
        return projectMicrobialMapper.selectListForApi();
    }

    @Override
    public List<ProjectMicrobial> selectMicrobialListByPlanId(Long planId) {
        return projectMicrobialMapper.selectMicrobialListByPlanId(planId);
    }

    @Override
    public List<ProjectMicrobial> selectUnMicrobialListByPlanId(Long planId) {
        return projectMicrobialMapper.selectUnMicrobialListByPlanId(planId);
    }

    /**
     * 新增菌剂
     * 
     * @param projectMicrobial 菌剂信息
     * @return 结果
     */
	@Override
	public int insertProjectMicrobial(ProjectMicrobial projectMicrobial) {
        projectMicrobial.setCreateBy(ShiroUtils.getLoginName());
	    return projectMicrobialMapper.insertProjectMicrobial(projectMicrobial);
	}
	
	/**
     * 修改菌剂
     * 
     * @param projectMicrobial 菌剂信息
     * @return 结果
     */
	@Override
	public int updateProjectMicrobial(ProjectMicrobial projectMicrobial) {
        projectMicrobial.setUpdateBy(ShiroUtils.getLoginName());
	    return projectMicrobialMapper.updateProjectMicrobial(projectMicrobial);
	}

	/**
     * 删除菌剂对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteProjectMicrobialByIds(String ids) {
		return projectMicrobialMapper.deleteProjectMicrobialByIds(Convert.toStrArray(ids));
	}

    @Override
    public List<ProjectMicrobial> selectMicroList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("1").build());
    }

    @Override
    public List<ProjectMicrobial> selectCsList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("2").microbialCategory("1").build());
    }

    @Override
    public List<ProjectMicrobial> selectPhosList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("2").microbialCategory("2").build());
    }

    @Override
    public List<ProjectMicrobial> selectFlocList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("2").microbialCategory("3").build());
    }

    @Override
    public List<ProjectMicrobial> selectOxidList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("2").microbialCategory("4").build());
    }

    @Override
    public List<ProjectMicrobial> selectOtherList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(ProjectMicrobial.builder().microbialType("2").microbialCategory("6").build());
    }

    @Override
    public List<ProjectMicrobial> selectMicrobialList() {
        return projectMicrobialMapper.selectProjectMicrobialListByType(null);
    }

}